const http = require('../utils/http.js');
const urlUserName = '/app/user/api/getByUserName';
const urlUser = '/app/user/api/getById';
const urlClassesId = '/app/user/api/list';

function getUserInfoByUserName(userName) {
  return http.get(urlUserName, { userName }).then(res => {
    return res.data;
  });
}

function getUserInfoById(userId) {
  return http.get(urlUser, { userId }).then(res => {
    return res.data;
  });
}

function getUsersInfoByClassesId(classesId, sex) {
  const data = {
    classesId: classesId,
    sex: sex
  };
  return http.get(urlClassesId, data).then(res => {
    return res.data;
  });
}

module.exports = {
  getUserInfoByUserName,
  getUserInfoById,
  getUsersInfoByClassesId
};
